{% extends 'base/nav.html' %}

{% block title %}修改密码 - 旅游舆情监测{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0"><i class="fa fa-key"></i> 修改密码</h4>
                </div>
                <div class="card-body">
                    {% if messages %}
                        {% for message in messages %}
                            <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                                {{ message }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                            </div>
                        {% endfor %}
                    {% endif %}

                    <form method="post">
                        {% csrf_token %}

                        <div class="mb-3">
                            <label class="form-label">{{ form.old_password.label }}</label>
                            {{ form.old_password }}
                            {% if form.old_password.errors %}
                                <div class="text-danger small">{{ form.old_password.errors }}</div>
                            {% endif %}
                        </div>

                        <div class="mb-3">
                            <label class="form-label">{{ form.new_password1.label }}</label>
                            {{ form.new_password1 }}
                            {% if form.new_password1.errors %}
                                <div class="text-danger small">{{ form.new_password1.errors }}</div>
                            {% endif %}
                            {% if form.new_password1.help_text %}
                                <div class="form-text">{{ form.new_password1.help_text }}</div>
                            {% endif %}
                        </div>

                        <div class="mb-3">
                            <label class="form-label">{{ form.new_password2.label }}</label>
                            {{ form.new_password2 }}
                            {% if form.new_password2.errors %}
                                <div class="text-danger small">{{ form.new_password2.errors }}</div>
                            {% endif %}
                        </div>

                        <div class="d-flex justify-content-between">
                            <a href="{% url 'users:center' %}" class="btn btn-secondary">取消</a>
                            <button type="submit" class="btn btn-primary">修改密码</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}